﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Classes;

namespace FlightSystemControlLayer
{
    class Program
    {
        static int noOfSeatsInOrder = 5;
        static Connection item;
        static DateTime departureTime = new DateTime(2010, 11, 21, 13, 50, 00);
        static Object ob = new Object();
        static void Main(string[] args)
        {
            SearcherCtr searcherCtr = new SearcherCtr();
            BookingCtr booker = new BookingCtr();
            City f = searcherCtr.getCityList()[5];
            City t = searcherCtr.getCityList()[9];
            
            //item = searcherCtr.MakeASearch(f, t).GetConnectionList()[0];

            //for (int i = 0; i < 5; i++)
            //{
            //    new Thread(Program.MultiTest).Start();
            //}
            Console.ReadLine();
           // methods below is the representation of Client output invoking search
           
            int nr = 1;

            foreach (Connection item in searcherCtr.MakeASearch(f, t, noOfSeatsInOrder, departureTime).GetConnectionList())
            {
                Console.WriteLine("-------" + nr++ + "--------");
                foreach (Flight fl in item.FlightList())
                {
                    Console.WriteLine(fl.From.Name + " > " + fl.To.Name);

                }
                Console.WriteLine("To book write 1 to see next 0");
                int bookNr = Convert.ToInt32(Console.ReadLine());
                if (bookNr == 0)
                {
                    
                }
                else {
                    Console.WriteLine("Booking was initiated   click Enter to exit");
                    booker.Book(item, noOfSeatsInOrder, "name", "lastname", "address", "country", "phone", "email", "passport" );
                    
                    Console.ReadLine();
                    break;
                
                }
            }
          
            

        } 
        
        
        private static void MultiTest() {
           
            BookingCtr booker = new BookingCtr();
            booker.Book(item, 100, "name", "lastname", "address", "country", "phone", "email", "passport");
        
        }
        
    }
    
   
}
